package com.example.lib_image

import android.graphics.Bitmap
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.net.Uri
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.databinding.BindingAdapter
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition


/**
 *@author Wcj
 *@description
 *@date 2022/6/21 11:55
 */
object MainDataBindingAdapter {
    @JvmStatic
    @BindingAdapter("avatarUrl")
    fun avatarUrl(imageView:ImageView,url:String){
        GlideApp.with(imageView.context)
            .load(url)
            .transform(CircleCrop())
            .placeholder(R.drawable.icon_default_avatar)
            .error(R.drawable.icon_default_avatar)
            .into(imageView)
    }
    @JvmStatic
    @BindingAdapter("textBold")
    fun textBold(textView: TextView, boolean: Boolean) {
        textView.typeface = if (boolean) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
    }

}